begintownscript;
variables;
short choice,i;
body;

beginstate init_state;
add_char_to_group(7,1);
add_char_to_group(8,1);
add_char_to_group(9,1);
add_char_to_group(10,1);
add_char_to_group(12,1);
add_char_to_group(16,1);
add_char_to_group(18,1);
add_char_to_group(20,1);


add_char_to_group(11,2);
add_char_to_group(13,2);
add_char_to_group(14,2);
add_char_to_group(15,2);

if(get_flag(250,7) > 0)
{	set_terrain(21,30,452);
	set_terrain(21,24,452);
	set_terrain(27,30,452);
	set_terrain(27,24,452);
}

break;

beginstate exit_state;
break;

beginstate start_state;
break;

beginstate 10;
move_to_new_town(9,25,4);
break;

beginstate 11;
set_attitude(1001,10);
set_attitude(6,10);

if(get_flag(3,15) == 0)
{	if(get_flag(10,9) > 0)
		message_dialog("Janok sits atop a raised platform in the middle of the room. He grimaces when he sees you enter. _You have tested my resolve and found me unwavering, what more do you seek?_","_I suppose if I'm to be tried then it must be more challenging than simple mind tricks, I will vanquish you here and never look back._ He doesn't seem at all concerned that you killed his golems, you soon see why.");
	if(get_flag(10,9) == 0)
	{	reset_dialog();
		add_dialog_str(0,"Janok sits atop a raised platform in the middle of the room, surrounded by his golem guards. He grimaces when he sees you enter. _You have tested my resolve and found me unwavering, what more do you seek?_",0);
		add_dialog_str(1,"_I suppose if I'm to be tried then it must be more challenging than simple mind tricks, I will vanquish you here and never look back._",0);
		add_dialog_str(2,"He calmly motions for his golems to charge you. Perhaps you made a mistake in coming here, there are quite a few of them, and they are only the beginning of your worries.",0);
		add_dialog_choice(0,"OK");
		choice = run_dialog(1);
		if(choice == 1)
}
	message_dialog("Janok casts a spell and the runes on the stone columns flanking him begin to glow. One of the pillars fires a bolt of energy at you, while another warps in several monsters.","Fighting pillars. You are at a loss about how to combat these. Perhaps magical explosions could damage them--they don't look particularly resilient.");
	set_flag(3,15,1);
}
break;

beginstate 12;
	message_dialog("Janok falls to the floor, mortally wounded. You raise your weapons to deliver the killing blow, but there is no need. _Dilecia, I am coming to join you!_ he whispers. With that he collapses.","With this maniac dead, Keilan is finally safe. You should report back to the mayor and Master Tuchin.");
	set_flag(250,7,1);
	set_flag(10,9,2);
	if(char_ok(4) == 1)
		set_flag(250,9,1);
i = 6;
while(i > 200)
{	if(char_ok(i) == 1)
		if(get_attitude(i) >= 10)
			kill_char(i,2,0);
	i = i + 1; }	
break;

beginstate 13;
	put_boom_on_space(21,30,1,0);
	run_animation_sound(152);
	set_terrain(21,30,452);
	put_stain_on_space(21,30,-1);
	force_instant_terrain_redraw();
	play_sound(108);
	message_dialog("The pillar crumbles and, thankfully, stops zapping you.","");
	erase_char(15);
break;

beginstate 14; // statuses
	put_boom_on_space(21,24,1,0);
	run_animation_sound(152);
	set_terrain(21,24,452);
	put_stain_on_space(21,24,-1);
	force_instant_terrain_redraw();
	play_sound(108);
	message_dialog("The pillar crumbles, Janok won't be receiving its positive status effects anymore.","");
	erase_char(14);
break;

beginstate 15; // summon
	put_boom_on_space(27,30,1,0);
	run_animation_sound(152);
	set_terrain(27,30,452);
	put_stain_on_space(27,30,-1);
	force_instant_terrain_redraw();
	play_sound(108);
	message_dialog("The pillar crumbles, the stream of summoned monsters that you've been contending with has now come to a halt.","");
	erase_char(11);
break;

beginstate 16; // heal
	put_boom_on_space(27,24,1,0);
	run_animation_sound(152);
	set_terrain(27,24,452);
	put_stain_on_space(27,24,-1);
	force_instant_terrain_redraw();
	play_sound(108);
	message_dialog("The pillar crumbles, it stops healing the nearby enemies as well.","");
	erase_char(13);
break;
